﻿//===============================================================================
// Microsoft Innovation Centre - Western Europe
// Copyright (c) 2008 Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Microsoft.WVB.Framework.DataServicesEntities;
using Microsoft.WVB.Silverlight.Infrastructure;

namespace Microsoft.WVB.UI
{
    [TemplateVisualState(GroupName = "CommonState", Name = "Iconed")]
    [TemplateVisualState(GroupName = "CommonState", Name = "Normal")]
    public partial class EPGView3 : UserControl
    {
        public List<Channel> epgChannelList3 = new List<Channel>();
        public EPGModel ViewModel { get; set; }

        public EPGView3()
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                ViewModel = IoC.GetCreate<EPGModel>();
                DataContext = ViewModel;
            }

            InitializeComponent();

            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                Action a = () => 
                { 
                    ViewModel.BuildTimelineHeader(timeTitles);
                };
                this.Dispatcher.BeginInvoke(a);
            }
        }
        
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //this.epgIconScrollView.ScrollToHorizontalOffset(epgScrollView.HorizontalOffset);
        }
    }

    public class WidthCalcConverter : IValueConverter
    {
        private static double EpgMinutesPerPixel = 0.5;

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            double d = Double.Parse(value.ToString());
            return d / EpgMinutesPerPixel;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class PositionCalcConverter : IValueConverter
    {
        private static double EpgMinutesPerPixel = 0.5;

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DateTime t = (DateTime)value;
            return ((t.Hour * 60) + t.Minute) / EpgMinutesPerPixel;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class TimeFormatConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DateTime t = (DateTime)value;
            return t.ToShortTimeString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}